package cn.seqdata.jpa.converter;

import java.util.UUID;

import javax.persistence.AttributeConverter;

public class GuidConverter implements AttributeConverter<UUID, String> {
	public static final GuidConverter instance = new GuidConverter();

	@Override
	public String convertToDatabaseColumn(UUID attribute) {
		return null != attribute ? attribute.toString() : null;
	}

	@Override
	public UUID convertToEntityAttribute(String dbData) {
		return null != dbData ? UUID.fromString(dbData) : null;
	}
}
